module ParserDemo where

import Text.ParserCombinators.Parsec
import InterlingualHomophones

parseH h n = do r <- parseFromFile interlingualHomophones n
                h r

handle (Left e)  = putStrLn (show e)
handle (Right r) = do p <- return (phoneticRelation r)
                      e <- return (equivalentsRelation r)
                      putStrLn $ showHomophones $ exportRelations p e

handleRel (Left e)  = putStrLn (show e)
handleRel (Right r) = do p <- return (phoneticRelation r)
                         e <- return (equivalentsRelation r)
                         putStrLn $ show $ exportRelations p e

parsePrint = parseH handle

parsePrintRelations = parseH handleRel

